package com.kim.androidbase.device;

import android.content.Context;
import android.content.res.Resources;

public class DeviceUtils {

	private Resources resources;
	private Context context;

	private static DeviceUtils instance;

	private DeviceUtils(Context context) {
		this.context = context;
	}

	public static DeviceUtils getInstance(Context context) {
		if (instance == null) {
			instance = new DeviceUtils(context);
			instance.resources = context.getResources();
		}
		return instance;
	}

	/**
	 * 获取设备宽度
	 * 
	 * @param context
	 * @return
	 */
	public final int getDeviceWidth() {
		return resources.getDisplayMetrics().widthPixels;
	}

	/**
	 * 获取设备高度
	 * 
	 * @param context
	 * @return
	 */
	public final int getDeviceHeight() {
		return resources.getDisplayMetrics().heightPixels;
	}

	/**
	 * 获取设备密度
	 * 
	 * @return
	 */
	public final int getDeviceDensity() {
		return resources.getDisplayMetrics().densityDpi;
	}
}
